package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysUserService;
import com.ruoyi.project.system.service.ISysUserServiceService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户收藏服务Controller
 * 
 * @author jjp
 * @date 2020-04-25
 */
@RestController
@RequestMapping("/system/service")
public class SysUserServiceController extends BaseController
{
    @Autowired
    private ISysUserServiceService sysUserServiceService;

    /**
     * 查询用户收藏服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserService sysUserService)
    {
        startPage();
        List<SysUserService> list = sysUserServiceService.selectSysUserServiceList(sysUserService);
        return getDataTable(list);
    }

    /**
     * 获取用户收藏服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{typeDetailId}")
    public AjaxResult getInfo(@PathVariable("typeDetailId") Long typeDetailId)
    {
        return AjaxResult.success(sysUserServiceService.selectSysUserServiceById(typeDetailId));
    }

    /**
     * 新增用户收藏服务
     */
    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "用户收藏服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserService sysUserService)
    {
        return toAjax(sysUserServiceService.insertSysUserService(sysUserService));
    }

    /**
     * 修改用户收藏服务
     */
    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "用户收藏服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserService sysUserService)
    {
        return toAjax(sysUserServiceService.updateSysUserService(sysUserService));
    }

    /**
     * 删除用户收藏服务
     */
    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "用户收藏服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeDetailIds}")
    public AjaxResult remove(@PathVariable Long[] typeDetailIds)
    {
        return toAjax(sysUserServiceService.deleteSysUserServiceByIds(typeDetailIds));
    }
}
